﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Quiz_Builder.Helpers;

namespace Quiz_Builder.ViewModel.TestTypes
{
    internal class FreeTextTestViewModel : BaseViewModel
    {
        #region Fields
        private ObservableCollection<AnswerStringItem> _answers;
        #endregion

        #region Properties
        public ObservableCollection<AnswerStringItem> Answers
        {
            get
            {
                if (_answers == null)
                    _answers = new ObservableCollection<AnswerStringItem>();
                return _answers;
            }
            set
            {
                _answers = value;
                RaisePropertyChanged("Answers");
            }
        }
        #endregion

        public FreeTextTestViewModel()
        {
            InitCommands();
        }

        #region Commands

        public ICommand AddNewAnswerCommand { get; set; }
        #endregion

        #region Methods
        private void InitCommands()
        {
            AddNewAnswerCommand = new RelayCommand(OnAddNewAnswer);
        }

        private void OnAddNewAnswer(object obj)
        {
            Answers.Add(new AnswerStringItem(String.Empty, String.Empty));
        }

        #endregion
    }
}
